package com.cgt.xiaotao.order.controller;

import com.cgt.common.domain.dto.PageDTO;
import com.cgt.common.utils.R;
import com.cgt.xiaotao.order.domain.dto.OrderAdminDTO;
import com.cgt.xiaotao.order.domain.query.OrderAdminQuery;
import com.cgt.xiaotao.order.service.IOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "订单接口-管理端")
@Slf4j
@RestController
@RequestMapping("/admin/ord")
@RequiredArgsConstructor
public class OrderAdminController {

    private final IOrderService orderService;

    @ApiOperation("分页条件查询订单列表")
    @PostMapping("/list")
    public R<PageDTO<OrderAdminDTO>> selectAdminPage(@RequestBody OrderAdminQuery query){
        try {
            PageDTO<OrderAdminDTO> page = orderService.selectAdminPage(query);
            return R.ok(page);
        }catch (Exception e) {
            return R.fail(e.getMessage());
        }
    }
}
